//
//  ViewController.swift
//  SwiftDemo
//
//  Created by John on 16/1/7.
//  Copyright (c) 2016 SteamCat_343. All rights reserved.
//


import UIKit


class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        self.view.backgroundColor = UIColor.whiteColor()
        self.title = "你好swift"
        
        let btn:UIButton = UIButton(frame: CGRect(x: UIScreen.mainScreen().bounds.size.width * 0.3, y: 250, width: 100, height: 40))
        btn.setTitle("点击按钮", forState: UIControlState.Highlighted)
        btn.setTitle("未点击", forState: UIControlState.Normal)
        btn.backgroundColor = UIColor.lightGrayColor()
        btn.addTarget(self, action: "clickEvent:", forControlEvents: UIControlEvents.TouchUpInside)
        self.view.addSubview(btn)
        
        let btnTable: UIButton = UIButton(frame: CGRectMake(UIScreen.mainScreen().bounds.size.width * 0.3, 320, 100, 40))
        btnTable.setTitle("点击跳转", forState: UIControlState.Normal)
        btnTable.backgroundColor = UIColor.blueColor()
        btnTable.addTarget(self, action: "clickTableButton", forControlEvents: UIControlEvents.TouchUpInside)
        self.view.addSubview(btnTable)
    }
    
        func clickEvent(sender:AnyObject) {
        
//            self .presentViewController(KeyboardViewController(), animated: false) { () -> Void in
            self.navigationController?.pushViewController(KeyboardViewController(), animated: true)
//            self.navigationController?.pushViewController(TreeTableViewController(), animated: true)
        }
        
//        let possibleNumber = "234"
//        let convertedNumber = Int(possibleNumber)
////        print("\(convertedNumber)")
//        if convertedNumber != nil {
//            print("convertNumber:\(convertedNumber) is not nil")
//        }
//        
//        var optionString: NSString
//        optionString = "123"
//        print((optionString))
//        
//        if var actualNumber = convertedNumber {
//            print("\(convertedNumber)has a value is \(actualNumber)")
//            actualNumber = 2345
//        }
//        do {
//            try canThrowAnError()
//            //没有错误信息
//        } catch {
//            //输出错误信息
//        }
    
    func clickTableButton() {
        self.navigationController?.pushViewController(TreeTableViewController(), animated: true)
    }
    
    func canThrowAnError() throws {
        
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()

    }




}
